package com.scedu.diy;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

//方式三：使用注解方式实现AOP
@Aspect
@Component
public class AnnontationPointCut {

    private final String POINT_CUT = "execution(* com.scedu.service.UserServiceImpl.*(..))";
    @Pointcut(POINT_CUT)
    public void pointCut(){//2.定义切点

    }
    @Before(value = "pointCut()")
    public  void before(){
        System.out.println("===方法执行前===");
    }
    @After(value =POINT_CUT )
    public  void after(){
        System.out.println("===方法执行后===");
    }
    @Around(value = POINT_CUT)
    public void around(ProceedingJoinPoint jp) throws Throwable {
        System.out.println("===环绕前===");
        //执行方法
        Object proceed = jp.proceed();
        System.out.println(" ===环绕后===");
    }
}
